package com.example.springbootdemo.utils;

import java.util.List;
import java.util.Random;

public class MathUtils {

    public static int[] getRandomIndex(int count, List list){
    Random random = new Random();
    int[] array = new int[count];
        for(int i = 0;i < array.length;i++){
        array[i] = -1;
    }

    int index = 0;
        while(index < array.length){
        int num = random.nextInt(list.size());
        if(contains(array,num)){
            array[index++] = num;
        }
    }

        for (int i = 0;i < array.length;i++){
        System.out.println(array[i]);
    }
        return array;//eee
}

    public static boolean contains(int[] arrry,int key){
        for(int i = 0;i < arrry.length;i++){
            if(arrry[i] == key){
                return false;
            }
        }
        return true;
    }
}
